package dados;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {
	
	Connection conn;
	
	private static Conexao instancia;
	
	public static Conexao ObterConexao(){
		if(instancia == null){
			instancia = new Conexao();
		}
		return instancia;
	}
	
	public Connection Conectar() throws ClassNotFoundException, SQLException{
		
		try{
			Class.forName("org.postgresql.Driver");
			String local = "localhost:5433";
			String banco = "sistemadistribuido";
			String usuario = "postgres";
			String senha = "123456";
			conn = DriverManager.getConnection("jdbc:postgresql://" +local+ "/" + banco + "?charSet=Latin1", usuario, senha);
			
			return conn;
					
		}catch (SQLException e){
			throw new RuntimeException(e);
			
		}
	}

} 
